<template>
  <div id="case">
    <h2 style="margin-top: 20px;">设备维护知识推荐</h2>

    <div class="search">
      故障现象：
      <el-input placeholder="请输入故障现象内容"
                prefix-icon="el-icon-search"
                slot="reference"
                v-model="searchInput"
                @keyup.enter.native="OnSubmit"
                style="width: 400px">
      </el-input>
    </div>

    <h3 style="margin-bottom: 30px; margin-top: 20px">查询结果</h3>
    <el-card shadow="hover" style="min-height: 200px">
      <el-table :data="k_data" style="width: 100%" highlight-current-row stripe @row-dblclick="double_click">
<!--        <el-table-column prop="ProblemCode" label="问题代码" min-width="100"></el-table-column>-->
        <el-table-column prop="Phenomenon"  label="故障现象" min-width="100"></el-table-column>
        <el-table-column prop="Describe" label="故障原因" min-width="100"></el-table-column>
<!--        <el-table-column prop="material" label="故障部件" min-width="100"></el-table-column>-->
        <el-table-column prop="Method" label="维修方法" min-width="100"></el-table-column>
<!--        <el-table-column prop="similarity" label="相似度" min-width="50"></el-table-column>-->
      </el-table>
    </el-card>
<!--    <h3 style="margin-bottom: 30px; margin-top: 20px">维护方案</h3>-->
<!--    <el-card shadow="hover" style="height: 200px"></el-card>-->
  </div>
</template>

<script>
import {request} from "../../network/2";

export default {
  name: "DQuery",
  data() {
    return {
      formInline: {
        device: '高压辊磨机',
        region: ''
      },
      k_data:[],
      searchInput:[],
    }
  },
  methods: {
    OnSubmit(e){
      if (e.keyCode == 13 && this.searchInput != "") {
        this.goSearch();
      }
    },
    goSearch () {
      console.log("1111111111");

      this.$router.push({ name: "device_query", params: { id: this.searchInput } });
      location.reload();
    },
    // 获取该行数据
    double_click(row_data){
      console.log(row_data);
      this.$store.commit({
        type:"update_res",
        payload:row_data
      });
      this.$router.push({name: 'detail'})
    },
    async GetRes(){
      let res = await request("/fsearch", {id: this.$route.params.id})
      console.log(res);
      this.k_data = res.data
      console.log(this.k_data);
    },
    // getData(){
    //   test().then(res =>{
    //     this.k_data = res.data
    //   })
    // }
  },
  created() {
    this.GetRes();
    console.log("++++++++++++++++++++++++")
  },

}
</script>

<style scoped>
.search{
  /*display: flex;*/
  text-align: center;
  /*align-items: center;*/
  margin-top: 20px;
}
</style>